package serveur;

import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.net.Socket;

import javax.imageio.ImageIO;
import mappingBD.Synchronisation;

public class Emission implements Runnable {

	private OutputStream out;
	private Synchronisation sync = null;
	private boolean donneeAEmettre = false;
	private ObjectOutputStream objectPourServeur = null;
	private Socket socket = null;

	public Emission(OutputStream out) {
		this.out = out;
	}

	public Emission() throws IOException {
		socket = Accepter_connexion.getSocket();
		this.out = socket.getOutputStream();

	}

	public void run() {
		try {
			objectPourServeur = new ObjectOutputStream(out);
		} catch (IOException e) {
			e.printStackTrace();
		}

		try {
			System.out.println("Envoyer une synchronisation au client...........");
			objectPourServeur.writeObject(sync);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	// GETTERS AND SETTERS

	public OutputStream getOut() {
		return out;
	}

	public void setOut(OutputStream out) {
		this.out = out;
	}

	public Synchronisation getSync() {
		return sync;
	}

	public void setSync(Synchronisation sync) {
		this.sync = sync;
	}

	public boolean isDonneeAEmettre() {
		return donneeAEmettre;
	}

	public void setDonneeAEmettre(boolean donneeAEmettre) {
		this.donneeAEmettre = donneeAEmettre;
	}

	public ObjectOutputStream getObjectPourServeur() {
		return objectPourServeur;
	}

	public void setObjectPourServeur(ObjectOutputStream objectPourServeur) {
		this.objectPourServeur = objectPourServeur;
	}

	public Socket getSocket() {
		return socket;
	}

	public void setSocket(Socket socket) {
		this.socket = socket;
	}

}
